package com.inthecheesefactory.lab.designlibrary;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import java.util.List;

/**
 * Created by FZT on 2016/3/14.
 */
public class GameJudgeReclerViewAdapter extends RecyclerView.Adapter<GameJudgeReclerViewAdapter.JudgeViewHolder> {
    private List<GameJudgeModel> gameJudgeModels;

    public GameJudgeReclerViewAdapter( List<GameJudgeModel> gameJudgeModels){
        this.gameJudgeModels=gameJudgeModels;

    }
    @Override
    public JudgeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.game_jadge_introduce_recyclerview_item,parent,false);
        JudgeViewHolder judgeViewHolder=new JudgeViewHolder(view);
        return judgeViewHolder;
    }

    @Override
    public void onBindViewHolder(JudgeViewHolder holder, int position) {
        GameJudgeModel gameJudgeModel=gameJudgeModels.get(position);
        holder.name.setText(gameJudgeModel.getName());
        holder.country.setText(gameJudgeModel.getCountry());
        holder.job.setText(gameJudgeModel.getJob());
        holder.networkImageView.setImageResource(gameJudgeModel.getImageId());
    }

    @Override
    public int getItemCount() {
        return gameJudgeModels==null ? 0 :gameJudgeModels.size();
    }

    class JudgeViewHolder extends RecyclerView.ViewHolder{

        private TextView name;
        private TextView country;
        private TextView job;
        private ImageView networkImageView;

        public JudgeViewHolder(View itemView) {
            super(itemView);
            name= (TextView) itemView.findViewById(R.id.tv_name);
            country= (TextView) itemView.findViewById(R.id.tv_country);
            job= (TextView) itemView.findViewById(R.id.tv_job );
            networkImageView= (ImageView) itemView.findViewById(R.id.niv_game_judge);
        }
    }
}
